#include("/common/include/include.html")
<style>
	.lay-body{
		margin-top: 52px;
		overflow-y: auto;
		overflow-x: unset;
	}
	.lay-header{
		position: absolute;
		top: 0px;
		width: 100%;
	}
</style>
<div class="modal-dialog" style="width:100%">
    <div class="modal-content" style="height: 100%;">
        <div class="modal-header lay-header">
            <button type="button" class="close" data-dismiss="modal" onclick="{parent.layer.closeAll();}"><i class="pci-cross pci-circle"></i></button>
            <h4 class="modal-title">选择单位</h4>
        </div>

        <div class="modal-body lay-body">
            <ul id="treeDemo" class="ztree"></ul>
        </div>
    </div>
</div>

<script>
	var ifOnlyLeaf = "#(ifOnlyLeaf)";
	//树
	var setting = {
		async : {
			enable : true,
			url : ctx + "/admin/sys/org/getOrgTree?orgid=#(orgid)&ifAllChild=#(ifAllChild)&ifOpen=#(ifOpen)&ifOnlyLeaf=#(ifOnlyLeaf)"
		},
		callback : {
			onClick : clickNode
		}
	};
	/***
	* 选择树
	**/
	function clickNode(event, treeId, treeNode, clickFlag) {
		if(ifOnlyLeaf==1){//只能选叶子
			var isParent = treeNode.isParent;
			if(isParent){
				parent.pointLion.alertMsg("请选择子节点" , "danger" , "small" ,null,null);
			}else{
				parent.pointLion.setOneOrgNode(treeNode);	
			}
		}else{
			parent.pointLion.setOneOrgNode(treeNode);
		}
	}
	$(document).ready(function() {
		$.fn.zTree.init($("#treeDemo"), setting);//初始化树
		var clientH = document.body.clientHeight-54;
		$(".lay-body").css("height",clientH+"px");
	});
</script>
